using System;
using System.Collections.Generic;
using System.Text;

using FinancialAnalyzer.ToolClasses;
using System.ComponentModel;

namespace FinancialAnalyzer.MoneyFlow
{
    [Serializable]
    public class MoneyFlowItem : INotifyPropertyChanged, IComparable<MoneyFlowItem>
    {
        private String _name;
        private EFlowDirection _flowDirection;
        private bool _isFixedMonthly;
        private double _fixedMonthlyValue;
        private double _valueValency;

        public MoneyFlowItem(String name, EFlowDirection direction,Boolean IsFixedMonthly, Double MonthlyValue, Double ValueValency)
        {
            _name = name;
            _flowDirection = direction;
            _isFixedMonthly = IsFixedMonthly;
            _fixedMonthlyValue = MonthlyValue;
            _valueValency = ValueValency;
        }

        public String Name
        {
            get { return _name; }
        }

        public EFlowDirection FlowDirection
        {
            get { return _flowDirection; }
            set { _flowDirection = value; this.NotifyPropertyChanged("FlowDirection"); }
        }

        public bool IsFixedMonthly
        {
            get { return _isFixedMonthly; }
            set { _isFixedMonthly = value; this.NotifyPropertyChanged("FixedMonthly"); }
        }
        
        public double FixedMonthlyValue
        {
            get { return _fixedMonthlyValue; }
            set { _fixedMonthlyValue = value; this.NotifyPropertyChanged("FixedMonthlyValue"); }
        }

        public double ValueValency
        {
            get { return _valueValency; }
            set { _valueValency = value; this.NotifyPropertyChanged("ValueValency"); }
        }

        #region INotifyPropertyChanged Member

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(string name)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(name));
        }

        #endregion

        #region IComparable<MoneyFlowItem> Member

        public int CompareTo(MoneyFlowItem other)
        {
            if (this.Name.Equals(other.Name))
            {
                return 0;
            }
            else
            {
                if (this.Name.ToLower()[0] > other.Name.ToLower()[0])
                {
                    return 1;
                }
                else
                {
                    return -1;
                }
            }
        }

        #endregion
    }
}
